package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.exception.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//@RestControllerAdvice(annotations = {RestController.class, Controller.class})
public class GlobalException {

    @ExceptionHandler(RuntimeException.class)
    public R catchCustonException(RuntimeException e){
        String message = e.getMessage();
        return  R.error(message);
    }

}
